// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutterdemo/0demo/main.dart';
import 'package:flutterdemo/1demo/common/utils/local_storage_util.dart';
import 'package:flutterdemo/2house730page/utils/regex.dart';

import 'package:flutterdemo/main.dart';
import 'package:shared_preferences/shared_preferences.dart';

void main() {
  testWidgets('Counter increments smoke test', (WidgetTester tester) async {
    // Build our app and trigger a frame.
    await tester.pumpWidget(MyApp());

    // Verify that our counter starts at 0.
    expect(find.text('0'), findsOneWidget);
    expect(find.text('1'), findsNothing);

    // Tap the '+' icon and trigger a frame.
    await tester.tap(find.byIcon(Icons.add));
    await tester.pump();

    // Verify that our counter has incremented.
    expect(find.text('0'), findsNothing);
    expect(find.text('1'), findsOneWidget);
  });

  test("String.split() splits the string on the delimiter", () {
    var string = "foo,bar,baz";
    expect(string.split(","), equals(["foo", "bar", "baz"]));
    print("aa");
  });

  test("sp", () {
    LocalStorageUtil.saveString("aaa", "aaa");
    Future<String> s = LocalStorageUtil.getString("aaa");
    s.then((value) => {print(value)});
  });

  test("regex", () {
    bool result = Regex.isEmail("790710584@1.c");
    print(result);
  });

  test("isNotEmpty", () {
    String s ="";
    print(s.isNotEmpty);
  });

  test("default class property", () {
    MyData myData = new MyData();
    print(myData);
  });

  test("String", () {
    String s= "a";
    String x = s;
    s = "b";
    print("x == $x");
  });
}

class MyData{
  String username = "11";
  int age = 2;
  bool sex = true;

  @override
  String toString() {
    return 'MyData{username: $username, age: $age, sex: $sex}';
  }
}
